package com.wjk.kylin.modules.generator.config;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 读取代码生成相关配置
 *
 * @author ruoyi
 */
@Component
@ConfigurationProperties(prefix = "gen")
@PropertySource(value = {"classpath:generator/generator.yml"})
public class GenConfig implements InitializingBean {
    //作者
    @Value("${author}")
    private String author;
    //生成包路径
    @Value("${packageName}")
    private String packageName;
    //自动去除表前缀，默认是false
    @Value("${autoRemovePre}")
    private boolean autoRemovePre;
    //表前缀(类名不会包含表前缀)
    @Value("${tablePrefix}")
    private String tablePrefix;

    public static String AUTH_OR;
    public static String PACKAGE_NAME;
    public static boolean AUTO_REMOVE_PRE;
    public static String TABLE_PREFIX;

    @Override
    public void afterPropertiesSet() throws Exception {
        AUTH_OR = author;
        PACKAGE_NAME = packageName;
        AUTO_REMOVE_PRE = autoRemovePre;
        TABLE_PREFIX = tablePrefix;
    }
}
